# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=apacket
pkgver=374.16e7036
pkgrel=2
groups=('blackarch' 'blackarch-networking' 'blackarch-sniffer')
pkgdesc='Sniffer syn and backscatter packets.'
arch=('x86_64' 'aarch64')
url='https://github.com/Acey9/apacket'
license=('custom:unknown')
depends=('glibc' 'libpcap')
makedepends=('git' 'go-pie')
source=("git+https://github.com/Acey9/$pkgname.git")
sha512sums=('SKIP')
_url='github.com/Acey9/apacket'
_url2='github.com/Acey9/sapacket'

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

build() {
  # Package does not use the new Golang build process because the repo was deleted
  # and tests can not be made.
  mkdir -p "src/$_url" && rm -rf "src/$_url" && mv apacket "src/$_url" &&
    cd "src/$_url"

  GOPATH="$srcdir" go get -d -t $_url
  GOPATH="$srcdir" go get -d -t $_url2
}

package() {
  install -dm 755 "$pkgdir/usr/bin"

  GOPATH="$srcdir" go build -v $_url
  GOPATH="$srcdir" go build -v $_url2

  install -Dm 755 "$srcdir/$pkgname" "$pkgdir/usr/bin/$pkgname"
  install -Dm 755 "$srcdir/sapacket" "$pkgdir/usr/bin/sapacket"
  install -Dm 644 "src/$_url/README.md" \
    "$pkgdir/usr/share/doc/$pkgname/README.md"
}

